package com.acwebsitedesign.uRateDrugs.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.acwebsitedesign.uRateDrugs.domain.Review;
import com.acwebsitedesign.uRateDrugs.domain.ReviewService;
import com.acwebsitedesign.uRateDrugs.domain.AccountService;

@Controller

public class RemoveReviewController {
	
	@Autowired
	ReviewService reviewService;
	
	@Autowired
	AccountService accountService;
	
	@RequestMapping("/removeReview.html")
	public ModelAndView removeReview() {

		Review deleteReview = new Review();
		ModelAndView mav = new ModelAndView("removeReview");
		mav.addObject(deleteReview);
		return mav;
	}
	
	@RequestMapping("/RemoveReviewByID.html")
	public ModelAndView removeReviewByID(@RequestParam int PId, @ModelAttribute("removeReview") Review deleteReview){
		reviewService.removeReview(PId);
		ModelAndView mav = new ModelAndView("ReviewRemovalComplete");
		return mav;
	}
	
	@RequestMapping("/removeAllReviewsForAUser.html")
	public ModelAndView removeAllReviewsForAUser(@RequestParam int UId, @ModelAttribute("removeReview") Review deleteReview){
		reviewService.removeAllReviewsForAUser(UId);
		ModelAndView mav = new ModelAndView("ReviewRemovalComplete");
		return mav;
	}
}